package main

import (
	"fmt"
	"time"
)

// 使用协程序交替打印1 2 1 2
func PrintDemo() {
	intChan := make(chan int)
	go print(intChan)
	go func() {
		for {
			data := <-intChan
			fmt.Println(data)
			intChan <- 1
		}
	}()

	go func() {
		for {
			intChan <- 2
			data := <-intChan
			fmt.Println(data)
		}
	}()

	time.Sleep(10 * time.Second)
}
